package com.wudimeng.syll.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wudimeng.syll.common.ApiResponse;
import com.wudimeng.syll.dao.ICRuKuXinXiDAO;
import com.wudimeng.syll.dao.ILiuRuLiuChuDuiXiangDAO;
import com.wudimeng.syll.entity.CRuKuXinXi;
import com.wudimeng.syll.entity.LiuRuLiuChuDuiXiang;
import com.wudimeng.syll.service.ICRuKuXinXiService;
import com.wudimeng.syll.service.ILiuRuLiuChuDuiXiangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class LiuRuLiuChuDuiXiangService implements ILiuRuLiuChuDuiXiangService {

    @Autowired
    private ILiuRuLiuChuDuiXiangDAO dao;

    @Override
    public ApiResponse selectLiuRuLiuChuDuiXiang(Map<String, String> paramMap) {
        return ApiResponse.instance(dao.selectLiuRuLiuChuDuiXiang(paramMap));
    }

    @Override
    public ApiResponse selectLiuRuLiuChuDuiXiangByID(String ID) {
        return ApiResponse.instance(dao.selectLiuRuLiuChuDuiXiangById(ID));
    }

    @Override
    public void addLiuRuLiuChuDuiXiang(LiuRuLiuChuDuiXiang liuRuLiuChuDuiXiang) {
        if(liuRuLiuChuDuiXiang.getWeiDu() != null && liuRuLiuChuDuiXiang.getYongHuID() == null){
            Integer yongHuId = dao.selectYongHuId(liuRuLiuChuDuiXiang.getWeiDu());
            liuRuLiuChuDuiXiang.setYongHuID(yongHuId);
        }
        dao.addLiuRuLiuChuDuiXiang(liuRuLiuChuDuiXiang);
    }

    @Override
    public void updLiuRuLiuChuDuiXiang(LiuRuLiuChuDuiXiang liuRuLiuChuDuiXiang) {
        dao.updLiuRuLiuChuDuiXiang(liuRuLiuChuDuiXiang);
    }

    @Override
    public void delLiuRuLiuChuDuiXiang(String ID) {
        dao.delLiuRuLiuChuDuiXiang(ID);
    }
}
